home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 326-350 / disk_337 / cmanual / gadgets.lzh / Gadgets / Gadgets.doc < prev   
Text File  |  1990-01-30  |  53KB  |  1,368 lines

  1. 4    GADGETS
  2.  
  3. 4.1  INTRODUCTION
  4.  
  5. In this chapter we will look at how the user can communicate
  6. with the program. All programs which uses Intuition should,
  7. if possible, be controlled by a mouse, since it is the most
  8. commonly used input device. Intuition's Gadgets will play a big
  9. role here.
  10.  
  11. A gadget can be a "button" which the user can click on, but it
  12. can also be a small knob which can be dragged (like a volume
  13. control on a radio). A gadget can even be a box where the user
  14. can enter a text string or a value. The advantages of using
  15. gadgets are almost uncountable. They are very well supported by
  16. Intuition which means that your program does hardly need to do
  17. anything, but still have an outstanding user interface which
  18. is both easy to understand as well as use.
  19.  
  20.  
  21.  
  22. 4.2  DIFFERENT TYPES OF GADGETS
  23.  
  24. There exist two types of gadgets: System gadgets, which we
  25. already have discussed in chapter 2.3 SYSTEM GADGETS, and
  26. Custom gadgets. For every window System gadgets always look
  27. the same, and are always placed in the same places. Custom
  28. Gadgets, however, can be placed wherever you want, and it is
  29. you who decide how they should look like.
  30.  
  31.  
  32.  
  33. 4.3  CUSTOM GADGETS
  34.  
  35. There exist four different types of Custom gadgets:
  36. - Boolean gadget        On/Off (True/False) button.
  37. - Proportional gadget   A small knob which can be moved around
  38.                         inside a container.
  39. - String gadgets        Gadget which enables the user to enter
  40.                         a string.
  41. - Integer gadget        Same as the String gadget, except that
  42.                         the user can only enter integer numbers.
  43.  
  44.  
  45.  
  46. 4.3.1  GRAPHICS FOR CUSTOM GADGETS
  47.  
  48. You can render the gadget with help of the high-level graphics
  49. utilities which are supported by Intuition (See chapter 3
  50. GRAPHICS for more information). You can render the gadget with
  51. help of a Border structure, or an Image structure. You can even
  52. have a different rendering when the gadget is selected,
  53. highlighted.
  54.  
  55. It is of course possible to open gadgets with no rendering at
  56. all. The Drag gadget (System gadget) is a good example.
  57.  
  58.  
  59.  
  60. 4.3.2  POSITION
  61.  
  62. You can position the gadget everywhere on the display. The
  63. position is normally relative to the top left corner of the
  64. displaying element (Window, Requester etc). If you want you
  65. can position the gadget relative to some other sides than the
  66. top left corner:
  67.  
  68. If you want the gadget to be placed 10 pixels out and 20 lines
  69. down from the top left corner of a window, you set LeftEdge to
  70. 10, and TopEdge to 20. (LeftEdge etc are elements in the Gadget
  71. structure which is described later in the chapter.)
  72.  
  73. If you on the other hand want the gadget to always be 20 pixels
  74. above the bottom border of the window, and 10 pixels to the left
  75. of the right border, you set LeftEdge to -10 and TopEdge to -20
  76. together with the Flags GRELRIGHT and GRELBOTTOM. (More about
  77. this later.)
  78.  
  79.  
  80.  
  81. 4.3.3  SIZE
  82.  
  83. You decide the width and height of the gadget (the select box
  84. of the gadget) by setting the Width and Height variables as
  85. desired.
  86.  
  87. If you set the Height to 25, the gadget will be 25 lines high.
  88.  
  89. If you on the other hand set the Height to -25 and you set the
  90. GRELHEIGHT flag, the gadget will always be 25 lines smaller
  91. than the containing element (window etc).
  92.  
  93. Same applies for the Width. If you set the Width to 50, the
  94. gadget will always be 50 pixels wide.
  95.  
  96. If you on the other hand set the Width to be -50 and you set
  97. the flag GRELWIDTH, the gadget will always be 50 pixels smaller
  98. than the containing element.
  99.  
  100.  
  101.  
  102. 4.4  INITIALIZE A CUSTOM GADGET
  103.  
  104. When you want to use a Custom gadget you need to declare and
  105. initialize a Gadget structure which look like this:
  106.  
  107. struct Gadget
  108. {
  109.   struct Gadget *NextGadget;
  110.   SHORT LeftEdge, TopEdge, Width, Height;
  111.   USHORT Flags;
  112.   USHORT Activation;
  113.   USHORT GadgetType;
  114.   APTR GadgetRender;
  115.   APTR SelectRender;
  116.   struct IntuiText *GadgetText;
  117.   LONG MutualExclude;
  118.   APTR SpecialInfo;
  119.   USHORT GadgetID;
  120.   APTR UserData;
  121. }
  122.  
  123. NextGadget:        A pointer to the next gadget in the list if
  124.                    there exist one, else NULL.
  125.  
  126. LeftEdge, TopEdge: Position of the gadget's select box relative
  127.                    to the displaying element.
  128.  
  129. Width, Height:     Width and height of the gadget's select box.
  130.  
  131. Flags:             You must set one of the following four
  132.                    highlighting flags: (The gadget is
  133.                    highlighted when it is selected)
  134.  
  135.                    GADGHCOMP:  Complement the colours of all
  136.                                pixels in the gadget's select
  137.                                box.
  138.  
  139.                    GADGHBOX:   Draw a box around the the
  140.                                gadget's select box.
  141.  
  142.                    GADGHIMAGE: Display an alternative Image/
  143.                                Border.
  144.  
  145.                    GADGHNONE:  No highlighting.
  146.  
  147.                    If the gadget should be rendered as an Image
  148.                    set the flag GADGIMAGE, otherwise (render it
  149.                    with a Border structure, or no rendering at
  150.                    all) clear this flag.
  151.  
  152.                    If you want the position and/or size of the
  153.                    gadget to be relative to the size of the
  154.                    displaying element, set the desired flags:
  155.  
  156.                    GRELBOTTOM: TopEdge is used as an offset
  157.                                relative to the bottom of the
  158.                                displaying element, instead of
  159.                                an offset relative to the top of
  160.                                the displaying element.
  161.  
  162.                    GRELRIGHT:  LeftEdge is used as an offset
  163.                                relative to the right edge of
  164.                                the displaying element, instead
  165.                                of an offset relative to the
  166.                                left edge of the displaying
  167.                                element.
  168.  
  169.                    GRELWIDTH:  Width describes an increment to
  170.                                the width of the displaying
  171.                                element, instead of describing
  172.                                the absolute width of the
  173.                                gadget.
  174.  
  175.                    GRELRIGHT:  Height describes an increment
  176.                                to the height of the displaying
  177.                                element, instead of describing
  178.                                the absolute height of the
  179.                                gadget.
  180.  
  181.                    If this gadget is a toggle-select gadget
  182.                    (see Activation flags) you can set the
  183.                    SELECTED flag, and the gadget will be
  184.                    selected and highlighted when opened. If
  185.                    not, the gadget will be unselected and non-
  186.                    highlighted when opened.
  187.                    
  188.                    You can also examine this field to see if
  189.                    the SELECTED flag is set or not. If it is
  190.                    set, the gadget is selected, else it is
  191.                    unselected.
  192.                    
  193.                    If you want that the gadget should be
  194.                    disabled when opened, you set the flag
  195.                    GADDISABLED. Your program can later change
  196.                    this by calling the functions OnGadget()
  197.                    (enables the gadget) and OffGadget()
  198.                    (disables the gadget).
  199.  
  200. Activation:        Set the flags for the desired effects:
  201.                    (More about these later...)
  202.                    
  203.                    GADGIMMEDIATE: If you want your program to
  204.                                   know immediately when the
  205.                                   user selects this gadget, you
  206.                                   should set this flag.
  207.  
  208.                    RELVERIFY:     If you want your program to
  209.                                   receive a message when the
  210.                                   user releases the gadget and
  211.                                   the pointer is still inside
  212.                                   the gadget's select box, you
  213.                                   should set this flag.
  214.  
  215.                    FOLLOWMOUSE:   Set this flag if you want
  216.                                   your program to receive mouse
  217.                                   positions every time the user
  218.                                   moves the mouse while this
  219.                                   gadget is selected.
  220.  
  221.                    TOGGLESELECT:  Each time the user selects
  222.                                   this gadget, the on/off state
  223.                                   of the gadget (as well as the
  224.                                   image) is toggled. Your
  225.                                   program can later check the
  226.                                   status of the gadget by
  227.                                   examining the SELECTED bit in
  228.                                   the Flags field.
  229.  
  230.                    BOOLEXTEND:    Set this flag if your gadget
  231.                                   has a BoolInfo structure
  232.                                   connected to it.
  233.  
  234.  
  235.                    If your gadget is connected to a window you
  236.                    can set the following flags in order to
  237.                    change the size of the window's borders.
  238.                    (You can then put the gadget there.):
  239.                    
  240.                    RIGHTBORDER:   The width of the window's
  241.                                   right border is calculated
  242.                                   with help of the gadget's
  243.                                   position and width.
  244.  
  245.                    LEFTBORDER:    The width of the window's
  246.                                   left border is calculated
  247.                                   with help of the gadget's
  248.                                   position and width.
  249.  
  250.                    TOPBORDER:     The height of the window's
  251.                                   top border is calculated
  252.                                   with help of the gadget's
  253.                                   position and height.
  254.  
  255.                    BOTTOMBORDER:  The height of the window's
  256.                                   bottom border is calculated
  257.                                   with help of the gadget's
  258.                                   position and height.
  259.  
  260.  
  261.                    If this gadget is connected to a requester
  262.                    you can set the ENDGADGET flag. The 
  263.                    requester will only go away when a gadget
  264.                    with the ENDGADGET flag has been selected.
  265.                    (See chapter 5 REQUESTERS for more
  266.                    information about gadgets connected to
  267.                    requesters.)
  268.  
  269.                    Intuition will only care about these flags
  270.                    if the gadget is a String/Integer gadget:
  271.                    
  272.                    STRINGRIGHT:   Set this flag if you want the
  273.                                   characters in the string to
  274.                                   be right-justified.
  275.  
  276.                    STRINGCENTER:  Set this flag if you want the
  277.                                   characters in the string to
  278.                                   be center-justified.
  279.                                   
  280.                   (The default is left-justified.)
  281.  
  282.                    LONGINT:       Set this flag if you want
  283.                                   that the user should only be
  284.                                   able to enter a 32-bit signed
  285.                                   integer value.
  286.  
  287.                    ALTKEYMAP:     Set this flag if you want to
  288.                                   use an alternative keymap.
  289.                                   Remember to give the AltKeyMap
  290.                                   pointer in the StringInfo
  291.                                   structure a pointer to the
  292.                                   keymap.
  293.  
  294. GadgetType:        You must set one of the following three
  295.                    flags:
  296.  
  297.                    BOOLGADGET:    Set this flag if you want a
  298.                                   Boolean gadget.
  299.  
  300.                    STRGADGET:     Set this flag if you want a
  301.                                   String/Integer gadget. If you
  302.                                   want an Integer gadget you
  303.                                   also need to set the
  304.                                   Activation flag LONGINT. 
  305.  
  306.                    PROPGADGET:    Set this flag if you want a
  307.                                   Proportional gadget.
  308.  
  309.                    The following two flags are only for gadgets
  310.                    connected to Gimmezerozero windows and
  311.                    requesters.
  312.  
  313.                    GZZGADGET:     If the gadget is connected to
  314.                                   a Gimmezerozero window and
  315.                                   you have set this flag, the
  316.                                   gadget will be put in the
  317.                                   outer window, and will not
  318.                                   destroy any drawings etc in
  319.                                   the inner window.
  320.                                   
  321.                    REQGADGET:     Set this flag if the gadget
  322.                                   is connected to a requester.
  323.  
  324. GadgetRender:      A pointer to an Image or Border structure
  325.                    (See chapter 3 GRAPHICS for more information)
  326.                    which will be used to render the gadget. (If
  327.                    you supply a pointer to an Image structure
  328.                    you need to set the Flags variable to
  329.                    GADGIMAGE.) Set it to NULL if you do not
  330.                    want to supply the gadget with any graphics.
  331.  
  332. SelectRender:      A pointer to an alternative Image or Border
  333.                    structure which will be used when the gadget
  334.                    is highlighted. Remember to set the
  335.                    GADGHIMAGE bit in the Flags variable if you
  336.                    want to use an alternative Image/Border.
  337.                    (GadgetRender and SelectRender must point to
  338.                    the same type of data. If you have specified
  339.                    that you want to use an Image for the
  340.                    GadgetRender (GADGIMAGE), SelectRender must
  341.                    then also point to an Image structure.)
  342.  
  343. GadgetText:        A pointer to an IntuiText structure (See
  344.                    chapter 3 GRAPHICS for more information)
  345.                    which will be used to print some text in the
  346.                    gadget. Set it to NULL if you do not want
  347.                    any text connected to your gadget.
  348.  
  349. MutualExclude:     This field represent the first 32 gadgets
  350.                    in the list. If this gadget is selected,
  351.                    all specified gadgets in the MutualExclude
  352.                    field are deselected automatically. For
  353.                    example, if you want that gadget number 0,
  354.                    2, 5 and 8 should be deselected (mutual
  355.                    excluded) when this gadget is selected, the
  356.                    MutualExclude field should be set to 293.
  357.                    ( 293(d) == 100100101(b) )
  358.                    
  359.                    Remember, the mutual exclude works only with
  360.                    toggle-select gadgets.
  361.  
  362. SpecialInfo:       If the gadget is a Proportional gadget you
  363.                    should here give Intuition a pointer to a
  364.                    PropInfo structure, or if the gadget is a
  365.                    String (Integer) gadget you should give
  366.                    Intuition a pointer to a StringInfo
  367.                    structure.
  368.                    
  369.                    If the gadget is a Boolean gadget you can
  370.                    connect a BoolInfo structure which will
  371.                    place a mask on the gadget's select box.
  372.                    (See below for more information.)
  373.  
  374. GadgetID           This variable is left for your own use.
  375.                    Intuition ignores this field.
  376.  
  377. UserData:          A pointer to any structure you may want
  378.                    to connect to the gadget. Intuition ignores
  379.                    this field.
  380.  
  381.  
  382.  
  383. 4.5  BOOLEAN GADGET
  384.  
  385. If you want a Boolean gadget you should declare and initialize
  386. the Gadget structure something like this:
  387.  
  388. struct my_gadget=
  389. {
  390.   NULL,          /* NextGadget, no more gadgets in the list. */
  391.   40,            /* LeftEdge, 40 pixels out. */
  392.   20,            /* TopEdge, 20 lines down. */
  393.   60,            /* Width, 60 pixels wide. */
  394.   20,            /* Height, 20 pixels lines high. */
  395.   GADGHCOMP,     /* Flags, when this gadget is highlighted, */
  396.                  /* the gadget will be rendered in the      */
  397.                  /* complement colours:                     */
  398.                  /* (Colour 0 (00) will become colour 3 (11) */
  399.                  /* (Colour 1 (01)        - " -       2 (10) */
  400.                  /* (Colour 2 (10)        - " -       1 (01) */
  401.                  /* (Colour 3 (11)        - " -       0 (00) */  
  402.   GADGIMMEDIATE| /* Activation, our program will receive a  */
  403.   RELVERIFY,     /* message when the user has selected this */
  404.                  /* gadget, and when the user has released  */
  405.                  /* it.                                     */ 
  406.   BOOLGADGET,    /* GadgetType, a Boolean gadget. */
  407.   &my_border,    /* GadgetRender, a pointer to our Border */
  408.                  /* structure.                            */
  409.   NULL,          /* SelectRender, NULL since we do not    */
  410.                  /* supply the gadget with an alternative */
  411.                  /* image. (We complement the colours     */
  412.                  /* instead.)                             */
  413.   &my_text,      /* GadgetText, a pointer to our IntuiText */
  414.                  /* structure.                             */
  415.   NULL,          /* MutualExclude, no mutual exclude. */
  416.   NULL,          /* SpecialInfo, no BoolInfo connected to it. */
  417.   0,             /* GadgetID, no id. */
  418.   NULL           /* UserData, no user data connected to the */
  419.                  /* gadget. */
  420. };
  421.  
  422.  
  423. It is possible to connect a mask to a Boolean gadget. In that
  424. case the gadget would only be selected when the user clicks
  425. inside the selected (masked) area, and only that area would be
  426. highlighted. If you want to connect a mask to a Boolean gadget
  427. you need to declare and initialize a BoolInfo structure
  428. together with its mask.
  429.  
  430. The BoolInfo structure look like this:
  431.  
  432. struct BoolInfo
  433. {
  434.   USHORT Flags;
  435.   UWORD *Mask;
  436.   ULONG Reserved;
  437. };
  438.  
  439. Flags:    There exist only one flag for the moment: BOOLMASK.
  440.  
  441. Mask:     Pointer to the binary mask. (The width and height of
  442.           the mask must be the same as the width and height of
  443.           the select box.)
  444.  
  445. Reserved: This field is reserved and should therefore be set
  446.           to 0.
  447.  
  448.  
  449. The binary mask is built up as an Image plane. Only the
  450. selected (1's) parts of the mask will be sensitive and
  451. highlighted.
  452.  
  453. A mask for a gadget with the width of 16 pixels, and the height
  454. of 8 pixels can look something like this: (Only the inner part
  455. of the select box will be sensitive and highlighted.)
  456.  
  457. Mask                16-Bit memory words    Hexadecimal
  458. ------------------------------------------------------
  459.  
  460. 0000001111000000    0000 0011 1100 0000    03C0
  461. 0000111111110000    0000 1111 1111 0000    0FF0
  462. 0011111111111100    0011 1111 1111 1100    3FFC
  463. 1111111111111111    1111 1111 1111 1111    FFFF
  464. 1111111111111111    1111 1111 1111 1111    FFFF
  465. 0011111111111100    0011 1111 1111 1100    3FFC
  466. 0000111111110000    0000 1111 1111 0000    0FF0
  467. 0000001111000000    0000 0011 1100 0000    03C0
  468.  
  469.  
  470. The mask would in this case be declared/initialized like this:
  471.  
  472. UWORD my_mask[]=
  473. {
  474.   0x03C0,
  475.   0x0FF0,
  476.   0x3FFC,
  477.   0xFFFF,
  478.   0xFFFF,
  479.   0x3FFC,
  480.   0x0FF0,
  481.   0x03C0
  482. };
  483.  
  484. See Example6 for more information about the BoolInfo structure.
  485.  
  486.  
  487.  
  488. 4.6  STRING/INTEGER GADGET
  489.  
  490. String and Integer gadgets are a bit more complicated to
  491. declare since you need to supply the Gadget structure with a
  492. StringInfo structure. However, String and Integer gadgets
  493. allows the user to enter a string or an integer value without
  494. much effort from your side. Intuition takes care of most of the
  495. work, and you almost only need to decide how long and where the
  496. string gadget should be.
  497.  
  498.  
  499.  
  500. 4.6.1  STRINGINFO STRUCTURE
  501.  
  502. The StringInfo structure look like this:
  503.  
  504. struct StringInfo
  505. {
  506.   UBYTE *Buffer;
  507.   UBYTE *UndoBuffer;
  508.   SHORT BufferPosition;
  509.   SHORT MaxChars;
  510.   SHORT DispPos;
  511.   SHORT UndoPos;
  512.   SHORT NumChars;
  513.   SHORT DispCount;
  514.   SHORT CLeft, CTop;
  515.   struct Layer *LayerPtr;
  516.   LONG LongInt;
  517.   struct KeyMap *AltKeyMap;
  518. };
  519.  
  520. Buffer:            A pointer to a NULL-terminated string.
  521.  
  522. UndoBuffer:        A pointer to a NULL-terminated string which
  523.                    is used by Intuition to store an undo string.
  524.                    This must be at least as long as the Buffer
  525.                    string. When the user selects this gadget
  526.                    Intuition makes a copy of the Buffer string
  527.                    which will be copied back if the user
  528.                    presses AMIGA + Q. Since only one String/
  529.                    Integer gadget can be active at a time
  530.                    several String/Integer gadgets can use the
  531.                    same undo string.
  532.  
  533. MaxChars:          The maximum number of characters which may
  534.                    be entered. (Number of characters in the
  535.                    buffer + the NULL '\0' sign.)
  536.  
  537. BufferPos:         Cursor position in the buffer string.
  538.  
  539. DispPos:           Position of the first character which is
  540.                    displayed.
  541.  
  542. These variables are initialized and maintained by Intuition:
  543.  
  544. UndoPos:           Cursor position in the undo string.
  545.  
  546. NumChars:          Current number of characters in the buffer.
  547.  
  548. DispCount:         Current number of visible characters in the
  549.                    container.
  550.  
  551. CLeft, CTop:       Top left offset of the container.
  552.  
  553. LayerPtr:          Pointer to the Layer structures.
  554.  
  555. LongInt:           If this is an Integer gadget you can examine
  556.                    the value here to find out what the user has
  557.                    entered.
  558.  
  559. AltKeyMap:         A pointer to an alternative keymap.
  560.                    (Remember to set the flag ALTKEYMAP in the
  561.                    Activation field.)
  562.  
  563.  
  564.  
  565. 4.6.2  INITIALIZE A STRING/INTEGER GADGET
  566.  
  567. This is an example on how you can initialize a string gadget:
  568.  
  569. UBYTE my_buffer[50];
  570. UBYTE my_undo_buffer[50];
  571.  
  572. struct StringInfo my_string_info=
  573. {
  574.   my_buffer,       /* Buffer, pointer to a NULL-terminated s. */
  575.   my_undo_buffer,  /* UndoBuffer, pointer to a NULL-          */
  576.                    /* terminated string. (Remember my_buffer  */
  577.                    /* is equal to &my_buffer[0])              */
  578.   0,               /* BufferPos, initial position of the */
  579.                    /* cursor.                            */
  580.   50,              /* MaxChars, 49 characters + NULL-sign. */
  581.   0,               /* DispPos, first character in the string */
  582.                    /* should be first character in the       */
  583.                    /* display.                               */
  584.  
  585.   /* Intuition initializes and maintains these variables: */
  586.  
  587.   0,               /* UndoPos */
  588.   0,               /* NumChars */
  589.   0,               /* DispCount */
  590.   0, 0,            /* CLeft, CTop */
  591.   NULL,            /* LayerPtr */
  592.   NULL,            /* LongInt */
  593.   NULL,            /* AltKeyMap */
  594. };
  595.  
  596. struct Gadget my_gadget=
  597. {
  598.   NULL,           /* NextGadget, no more gadgets in the list. */
  599.   68,             /* LeftEdge, 68 pixels out. */
  600.   30,             /* TopEdge, 30 lines down. */
  601.   198,            /* Width, 198 pixels wide. */
  602.   8,              /* Height, 8 pixels lines high. */
  603.   GADGHCOMP,      /* Flags, draw the select box in the        */
  604.                   /* complement colours. Note: it is actually */
  605.                   /* only the cursor which will be drawn in   */
  606.                   /* the complement colours (yellow). If you  */
  607.                   /* set the flag GADGHNONE the cursor will   */
  608.                   /* not be highlighted, and the user will    */
  609.                   /* therefore not be able to see it.         */
  610.   GADGIMMEDIATE|  /* Activation, our program will receive a  */
  611.   RELVERIFY,      /* message when the user has selected this */
  612.                   /* gadget, and when the user has released  */
  613.                   /* it.                                     */ 
  614.   STRGADGET,      /* GadgetType, a String gadget. */
  615.   &my_border,     /* GadgetRender, a pointer to our Border */
  616.                   /* structure.                            */
  617.   NULL,           /* SelectRender, NULL since we do not    */
  618.                   /* supply the gadget with an alternative */
  619.                   /* image.                                */
  620.   &my_text,       /* GadgetText, a pointer to our IntuiText */
  621.                   /* structure.                             */
  622.   NULL,           /* MutualExclude, no mutual exclude. */
  623.   &my_string_info,/* SpecialInfo, a pointer to a StringInfo */
  624.                   /* structure. */
  625.   0,              /* GadgetID, no id. */
  626.   NULL            /* UserData, no user data connected to the */
  627.                   /* gadget.                                 */
  628. };
  629.  
  630. The only difference between declaring and initializing a String
  631. gadget and an Integer gadget, is that when you initialize an
  632. Integer gadget you also need to:
  633.  
  634. 1. Set the flag LONGINT in the Activation field.
  635. 2. Copy an integer string into the buffer string.
  636.    eg: strcpy( my_buffer, "0" );
  637.  
  638.  
  639.  
  640. 4.6.3  USING A STRING/INTEGER GADGET
  641.  
  642. Once you have declared and initialized the appropriate
  643. structures Intuition takes care of everything else. While the
  644. user is entering a string he/she can even use some special
  645. keys:
  646.  
  647.   ------------------------------------------------------------
  648.   | <-            Moves the cursor to the left.              |
  649.   | ->            Moves the cursor to the right.             |
  650.   | SHIFT and <-  Moves the cursor to the beginning of the   |
  651.   |               string.                                    |
  652.   | SHIFT and ->  Moves the cursor to the end of the string. |
  653.   | BACKSPACE     Deletes the character to the left of the   |
  654.   |               cursor.                                    |
  655.   | DEL           Deletes the character under the cursor.    |
  656.   | AMIGA and Q   Undo the last changes of the string.       |
  657.   | AMIGA and X   Clears the buffer string.                  |
  658.   | RETURN        Releases the gadget. If we have set the    |
  659.   |               activation flag RELVERIFY we will receive  |
  660.   |               a message telling us that the user has     |
  661.   |               finished.                                  |
  662.   ------------------------------------------------------------
  663.  
  664.  
  665.  
  666. 4.7  PROPORTIONAL GADGET
  667.  
  668. A proportional gadget is roughly a knob which can be moved
  669. horizontally, vertically or both inside a container. It can be
  670. like a volume control on a radio, or it can be used to show the
  671. user how much more data there exist in the file etc.
  672.  
  673.  
  674.  
  675. 4.7.1  PROPINFO STRUCTURE
  676.  
  677. The PropInfo structure look like this:
  678.  
  679. struct PropInfo
  680. {
  681.   USHORT Flags;
  682.   USHORT HorizPot;
  683.   USHORT VertPot;
  684.   USHORT HorizBody;
  685.   USHORT VertBody;
  686.   USHORT CWidth;
  687.   USHORT CHeight;
  688.   USHORT HPotRes, VPotRes;
  689.   USHORT LeftBorder;
  690.   USHORT TopBorder;
  691. };
  692.  
  693. Flags:             You normally should set one or both of the
  694.                    following two bits:
  695.  
  696.                    FREEHORIZ      Set this bit if you want the
  697.                                   user to be able to move the
  698.                                   knob horizontally.
  699.  
  700.                    FREEVERT       Set this bit if you want the
  701.                                   user to be able to move the
  702.                                   knob vertically.
  703.                    
  704.                    AUTOKNOB       Set this bit if you want that
  705.                                   the size of the knob to be
  706.                                   controlled by Intuition.
  707.                                   (HorizBody and VertBody
  708.                                   affects the size of the
  709.                                   Autoknob.)
  710.  
  711.                                   - If you want to use
  712.                                   Intuition's Autoknob you
  713.                                   should give GadgetRender a
  714.                                   pointer to an Image structure.
  715.                                   (You do not need to initialize
  716.                                   the Image structure since
  717.                                   Intuition takes care of it.)
  718.  
  719.                                   - If you on the other hand
  720.                                   would like to use your own
  721.                                   knob image, you give
  722.                                   GadgetRender a pointer to your
  723.                                   Image structure, which you have
  724.                                   initialized yourself.
  725.  
  726.                    PROPBORDERLESS Set this bit if you do not
  727.                                   want any border around the
  728.                                   container. 
  729.  
  730.                    KNOBHIT        This is a flag which is set by
  731.                                   Intuition if this gadget is
  732.                                   selected.
  733.  
  734. HorizPot:          This variable contains the actual
  735.                    (horizontally) proportional value. If the
  736.                    user has moved the knob 25% to the right,
  737.                    HorizPot is 25% of MAXPOT (0xFFFF).
  738.                    (0xFFFF * 0.25 = 0x3FFF)
  739.  
  740. VertPot:           Same as HorizPot except that this is the
  741.                    vertically proportional value.
  742.  
  743. HorizBody:         Describes how much HorizPot should change
  744.                    every time the user clicks inside the
  745.                    container. If the volume of a melody can be
  746.                    between 0-63 (64 steps), HorizPot should
  747.                    change 1/64 each time. The HorizBody should
  748.                    therefore be initialized to:
  749.                    1/64 * MAXBODY (0xFFFF) == 3FF
  750.  
  751.                    HorizBody describes also how much the user
  752.                    can see/use of the entire data. For example,
  753.                    if you have a list of 32 file names, and the
  754.                    user only can see 8 names at one time (25%),
  755.                    the knob (AUTOKNOB) should fill 25% of the
  756.                    container. HorizBody should in this case be
  757.                    initialized to:
  758.                    MAXBODY * 8 / 32 (25% of 0xFFFF) == 3FFFF
  759.  
  760. VertBody:          Same as HorizBody except that it affects
  761.                    VertPot, and the vertical size of the knob
  762.                    (AUTOKNOB).
  763.  
  764. These variables are initialized and maintained by Intuition:
  765.  
  766. CWidth:            Width of the container.
  767.  
  768. CHeight:           Height of the container.
  769.  
  770. HPotRes, VPotRes:  Pot increments.
  771.  
  772. LeftBorder:        Position of the container's left border.
  773.  
  774. TopBorder:         Position of the container's top border.
  775.  
  776.  
  777.  
  778. 4.7.2  INITIALIZE A PROPORTIONAL GADGET
  779.  
  780. This is an example on how you can initialize a proportional
  781. gadget which can, for example, be used to change the volume of
  782. a melody (64 positions):
  783.  
  784. /* We need to declare an Image structure for the knob, but */
  785. /* since Intuition will take care of the size etc of the   */
  786. /* knob, we do not need to initialize the Image structure: */
  787. struct Image my_image;
  788.  
  789. struct PropInfo my_prop_info=
  790. {
  791.   FREEHORIZ|      /* Flags, the knob should be moved         */
  792.   AUTOKNOB,       /* horizontally, and Intuition should take */
  793.                   /* care of the knob image.                 */
  794.   0,              /* HorizPot, start position of the knob. */
  795.   0,              /* VertPot, 0 since we will not move the */
  796.                   /* knob vertically. */
  797.   MAXBODY * 1/64, /* HorizBody, 64 steps. */
  798.   0,              /* VertBody, 0 since we will not move the */
  799.                   /* knob vertically. */
  800.  
  801.   /* These variables are initialized and maintained by */
  802.   /* Intuition:                                        */
  803.  
  804.   0,              /* CWidth */
  805.   0,              /* CHeight */
  806.   0, 0,           /* HPotRes, VPotRes */
  807.   0,              /* LeftBorder */
  808.   0               /* TopBorder */
  809. };
  810.  
  811. struct Gadget my_gadget=
  812. {
  813.   NULL,            /* NextGadget, no more gadgets. */
  814.   80,              /* LeftEdge, 80 pixels out. */
  815.   30,              /* TopEdge, 30 lines down. */
  816.   200,             /* Width, 200 pixels wide. */
  817.   12,              /* Height, 12 pixels lines high. */
  818.   GADGHCOMP,       /* Flags, no highlighting. */
  819.   GADGIMMEDIATE|   /* Activation, our program will receive a  */
  820.   RELVERIFY,       /* message when the user has selected this */
  821.                    /* gadget, and when the user has released  */
  822.                    /* it.                                     */
  823.   PROPGADGET,      /* GadgetType, a Proportional gadget. */
  824.   &my_image,       /* GadgetRender, a pointer to our Image */
  825.                    /* structure. (Intuition will take care */
  826.                    /* of the knob image. See chapter 3     */
  827.                    /* GRAPHICS for more information about  */
  828.                    /* images.)                             */
  829.   NULL,            /* SelectRender, NULL since we do not    */
  830.                    /* supply the gadget with an alternative */
  831.                    /* image.                                */
  832.   &my_text,        /* GadgetText, pointer to a IntuiText */
  833.                    /* structure. */
  834.   NULL,            /* MutualExclude, no mutual exclude. */
  835.   &my_prop_info,   /* SpecialInfo, pointer to a PropInfo */
  836.                    /* structure. */
  837.   0,               /* GadgetID, no id. */
  838.   NULL             /* UserData, no user data connected to */
  839.                    /* the gadget. */
  840. };
  841.  
  842.  
  843.  
  844. 4.8  MONITORING THE GADGETS
  845.  
  846. Once you have decided which gadgets to use and how they should
  847. look like, it is time to decide what information they should
  848. send to your program. You need to decide if they should send a
  849. message when the user has selected them, or when the user has
  850. released them etc. All this work with handling the input can be
  851. easily done with help of Intuition's IDCMP system. IDCMP stands
  852. for Intuition's Direct Communications Message Ports system.
  853. Hard name but very easy use.
  854.  
  855. The IDCMP system is also explained, in more detail, in chapter
  856. 8 IDCMP. 
  857.  
  858. If you want to use the IDCMP system you only need to follow
  859. these steps:
  860.  
  861. 1. Decide what events your gadget should report. You do it by
  862.    setting the appropriate flags in the Activation field in the
  863.    Gadget structure:
  864.    
  865.    GADGIMMEDIATE  Set this flag if you want your program to
  866.                   receive a message immediately when the user
  867.                   selects this gadget.
  868.  
  869.    RELVERIFY      Set this flag if you want your program to
  870.                   receive a message when the user releases
  871.                   (while still pointing at it) this gadget. If
  872.                   the user releases the gadget after having
  873.                   moved away the pointer from the select box,
  874.                   your program will not receive any message.
  875.  
  876.    FOLLOWMOUSE    Set this flag if you want your program to
  877.                   receive a message every time the mouse is
  878.                   moved while this gadget is selected. 
  879.  
  880.  
  881. 2. If the gadgets are connected to a window you need to tell
  882.    Intuition which messages should be allowed to pass by. You
  883.    do it by setting the appropriate flags in the IDCMPFlags
  884.    field in the NewWindow structure:
  885.  
  886.    GADGETDOWN     If a gadget connected to a window has the
  887.                   GADGIMMEDIATE flag set, you should set the
  888.                   GADGETDOWN flag.
  889.  
  890.    GADGETUP       If a gadget connected to a window has the
  891.                   RELVERIFY flag set, you should set the
  892.                   GADGETUP flag.
  893.  
  894.    MOUSEMOVE      If a gadget connected to a window has the
  895.                   FOLLOWMOUSE flag set, you should set the
  896.                   MOUSEMOVE flag.
  897.  
  898.    CLOSEWINDOW    If you have connected the Close window gadget
  899.                   (System gadget) to your window, you can set
  900.                   this bit, and your program will receive a
  901.                   message when the user selects this gadget.
  902.                   Remember, Intuition does not close the window
  903.                   automatically when the user clicks on the
  904.                   Close window gadget. It is up to your program
  905.                   to decide what to do when you receive a
  906.                   CLOSEWINDOW event. (See Example1)
  907.  
  908.  
  909. 3. Once your program is running it is time to try to collect
  910.    and examine the messages sent to us by Intuition. One very
  911.    commonly used way of doing it is to put the program to sleep
  912.    [ Wait() ] and it will wake first when a message has
  913.    arrived. We will then try to collect it [ GetMsg() ], and
  914.    then (if success) examine the message. When we are finished
  915.    with it we send it back [ ReplyMsg() ] so Intuition can send
  916.    us another message if there is one. We can then put the
  917.    program to sleep again, and so on.
  918.    
  919. When we collect a message with help of the function GetMsg() we
  920. actually receive a pointer to an IntuiMessage structure or NULL
  921. if there was nothing for us. The IntuiMessage structure look
  922. like this:
  923.  
  924. struct IntuiMessage
  925. {
  926.   struct Message ExecMessage;
  927.   ULONG Class;
  928.   USHORT Code;
  929.   USHORT Qualifier;
  930.   APTR IAddress;
  931.   SHORT MouseX, MouseY;
  932.   ULONG Seconds, Micros;
  933.   struct Window *IDCMPWindow;
  934.   struct IntuiMessage *SpecialLink;
  935. };
  936.  
  937. This structure is fully explained in chapter 8 IDCMP, so you do
  938. not need to bother so much about it for the moment. However,
  939. there is two variables in the structure that we need to
  940. understand. They are:
  941.  
  942. Class:        When a message is sent this field contains the
  943.               reason for why it was sent. It contains an IDCMP
  944.               flag which tells us what has happened. For
  945.               example, if the user has selected a gadget with
  946.               the GADGIMMEDIATE flag set, this variable is
  947.               equal to GADGETDOWN.
  948.  
  949. IAddress:     This is a pointer to the gadget (or similar)
  950.               which sent the message. For example, if a program
  951.               receives a message telling us that a gadget was
  952.               selected, we need to know which gadget since
  953.               there may be several gadget connected to the same
  954.               window. This pointer points to that gadget.
  955.  
  956. Here is an example of how a program which collects IDCMP
  957. messages can look like:
  958.  
  959. main()
  960. {
  961.   /* Declare a variable in which we will store the IDCMP */
  962.   /* flag: */
  963.   ULONG class;
  964.   
  965.   /* Declare a pointer in which we will store the address */
  966.   /* of the object (gadget) which sent the message: */
  967.   APTR address;
  968.  
  969.   /* Declare a pointer to an IntuiMessage structure: */
  970.   struct IntuiMessage *my_message;
  971.  
  972.  
  973.   /* ... */
  974.  
  975.  
  976.   /* (This is an endless loop) */
  977.   while( TRUE )
  978.   {
  979.     /* 1. Put our program to sleep, and wake up first when   */
  980.     /*    we have received a message. Do not bother for the  */
  981.     /*    moment about all these funny thing we put inside   */
  982.     /*    the Wait () function. I will talk about that later */
  983.     /*    on.                                                */
  984.     
  985.     /* Wait until we have received a message: */
  986.     Wait( 1 << my_window->UserPort->mp_SigBit );
  987.  
  988.  
  989.  
  990.     /* 2. We have now received a message and we shall now     */
  991.     /*    try to collect it. If success the function GetMsg() */
  992.     /*    will return a pointer to an IntuiMessage            */
  993.     /*    structure, otherwise it will return NULL.           */
  994.    
  995.     /* Collect the message: */
  996.     my_message = GetMsg( my_window->UserPort );
  997.  
  998.  
  999.  
  1000.     /* 3. If we have collected a message successfully we save */
  1001.     /*    some important values which we later can use.       */
  1002.     
  1003.     if( my_message )
  1004.     {
  1005.       /* Save the code variable: */
  1006.       class = my_message->Class;
  1007.       
  1008.       /* Save the address of the gadget: */
  1009.       address = my_message->IAddress;
  1010.  
  1011.  
  1012.       /* 4. After we have saved all important values we     */
  1013.       /*    reply as fast as possible. Once we have replied */
  1014.       /*    we can NOT use the IntuiMessage structure any   */
  1015.       /*    more!                                           */
  1016.       
  1017.       ReplyMsg( my_message );
  1018.  
  1019.   
  1020.       /* 5. We can now check what message was sent to us. */
  1021.  
  1022.       /* Check which IDCMP flag was sent: */
  1023.       switch( class )
  1024.       {
  1025.         case GADGETDOWN: /* The user has selected a gadget: */
  1026.                
  1027.                /* If we want to check which gadget sent the */
  1028.                /* message we simply need to check the       */
  1029.                /* address pointer:                          */
  1030.                
  1031.                if( address == &my_first_gadget)
  1032.                  /* The gadget "my_first_gadget" selected. */
  1033.                  /* Do what ever you want... */
  1034.  
  1035.                if( address == &my_second_gadget)
  1036.                  /* The gadget "my_second_gadget" selected. */
  1037.                  /* Do what ever you want... */
  1038.  
  1039.                break;
  1040.  
  1041.         case GADGETUP: /* The user has released a gadget: */
  1042.                /* Do what ever you want... */
  1043.                break;
  1044.  
  1045.         case MOUSEMOVE: /* The user has moved the mouse */
  1046.                         /* while a gadget was selected. */
  1047.                /* Do what ever you want... */
  1048.                break;
  1049.  
  1050.         case CLOSEWINDOW: /* The user has selected the close */
  1051.                           /* window gadget. Time to quit.    */
  1052.                /* Do what ever you want... */
  1053.                break;
  1054.       }
  1055.     }
  1056.   }
  1057.  
  1058.   
  1059.   /* ... */
  1060. }   
  1061.  
  1062.  
  1063.  
  1064. 4.9  FUNCTIONS
  1065.  
  1066. Here are some commonly used functions:
  1067.  
  1068. RefreshGadgets()
  1069.  
  1070.   This function redraws all the gadgets in the list, starting
  1071.   by the specified gadget. If you for example has added or
  1072.   deleted a gadget you need to call this function to see the
  1073.   changes. On the other hand, if you have changed the imagery
  1074.   of a gadget, or the gadget's image has been trashed by
  1075.   something, you can also use this function to refresh the
  1076.   display.
  1077.   
  1078.   Synopsis:  RefreshGadgets( gadget, window, requester);
  1079.  
  1080.   gadget:    (struct Gadget *) Pointer to the gadget where the
  1081.              redrawing should start. This gadget, and all the
  1082.              following gadgets in the list will be redrawn.
  1083.  
  1084.   window:    (struct Window *) Pointer to the window which the
  1085.              gadgets are connected to.
  1086.   
  1087.   requester: (struct Requester *) If the gadget is connected to
  1088.              a requester, set this pointer to point to that
  1089.              requester, else NULL. Important, if this gadget is
  1090.              connected to a requester, it must be displayed
  1091.              when you execute this command! (See chapter 5
  1092.              REQUESTERS for more information about requesters.)
  1093.  
  1094.  
  1095. AddGadget()
  1096.  
  1097.   This function adds a gadget to the gadget list.
  1098.  
  1099.   Synopsis: result = AddGadget( window, gadget, position );
  1100.   
  1101.   result:   (long) The actual position of the gadget when it
  1102.             has been added.
  1103.  
  1104.   window:   (struct Window *) Pointer to the window, to which
  1105.             the gadget should be added.
  1106.  
  1107.   gadget:   (struct Gadget *) Pointer to the gadget which will
  1108.             be added.  
  1109.  
  1110.   position: (long) Position in the gadget list. (Starts from
  1111.             zero). Eg:
  1112.               0 -> Before all other gadgets.
  1113.               1 -> After the first gadget, but before the
  1114.                    second.
  1115.               If a too big value is entered (or -1), the gadget
  1116.               will be placed last in the list.
  1117.  
  1118.  
  1119.   Important, after your program has added the necessary
  1120.   gadgets, you need to call the function RefreshGadgets() in
  1121.   order to see your changes. You may add (or take away) several
  1122.   gadgets, but when you are finished you must call that
  1123.   function.
  1124.  
  1125.  
  1126. RemoveGadget()
  1127.  
  1128.   This function removes a gadget from the list:
  1129.   
  1130.   Synopsis: result = RemoveGadget( window, gadget );
  1131.  
  1132.   result:   (long) The position of the removed gadget or -1 if
  1133.             something went wrong.
  1134.  
  1135.   window:   (struct Window *) Pointer to the window that the
  1136.             gadget is connected to.
  1137.  
  1138.   gadget:   (struct Gadget *) Pointer to the gadget which will
  1139.             be removed.  
  1140.  
  1141.  
  1142.   Important, after your program has removed the necessary
  1143.   gadgets, you need to call the function RefreshGadgets() in
  1144.   order to see your changes. You may take away (or add) several
  1145.   gadgets, but when you are finished you must call that
  1146.   function.
  1147.  
  1148.  
  1149. OnGadget()
  1150.  
  1151.   This function enables a gadget (removes the GADGDISABLED bit
  1152.   in the gadget structure's Flags field):
  1153.   
  1154.   Synopsis: OnGadget( gadget, window, requester );
  1155.  
  1156.   gadget:     (struct Gadget *) Pointer to the gadget which
  1157.               will be enabled.
  1158.  
  1159.   window:     (struct Window *) Pointer to the window that the
  1160.               gadget is attached to.
  1161.   
  1162.   requester:  (struct Requester *) If the gadget is connected
  1163.               to a requester, set this pointer to point to that
  1164.               requester, else NULL. Important, if this gadget
  1165.               is connected to a requester, it must be displayed
  1166.               when you execute this command!
  1167.  
  1168.   Remember, as long as the gadget is disabled the user can not
  1169.   select it, and it will not broadcast any messages. A disabled
  1170.   gadget is drawn as usual except that it "ghosted".
  1171.  
  1172.  
  1173. OffGadget()
  1174.  
  1175.   This function disables a gadget (sets the GADGDISABLED bit in
  1176.   the gadget structure's Flags field):
  1177.   
  1178.   Synopsis:  OffGadget( gadget, window, requester );
  1179.  
  1180.   gadget:    (struct Gadget *) Pointer to the gadget which will
  1181.              be disabled.
  1182.  
  1183.   window:    (struct Window *) Pointer to the window that the
  1184.              gadget is attached to.
  1185.  
  1186.   requester: (struct Requester *) If the gadget is connected to
  1187.              a requester, set this pointer to point to that
  1188.              requester, else NULL. Important, if this gadget is
  1189.              connected to a requester, it must be displayed
  1190.              when you execute this command!
  1191.  
  1192.  
  1193. ModifyProp()
  1194.  
  1195.   This function modifies a proportional gadget's values and
  1196.   knob. For example, if your program is reading files from the
  1197.   disk, VertBody was maybe equal to 0xFFFF (MAXBODY) in the
  1198.   beginning, but as more files are collected from the disk, you
  1199.   maybe want to change the size of the knob etc. You then
  1200.   simply call this function and it will change the values as
  1201.   well as redraw the gadget.
  1202.   
  1203.   Synopsis:    ModifyProp( gadget, window, requester, flags,
  1204.                horiz_pot, vert_pot, horiz_body, vert_body ); 
  1205.  
  1206.   gadget:      (struct Gadget *) Pointer to the proportional
  1207.                gadget which should be changed and redrawn.
  1208.  
  1209.   window:      (struct Window *) Pointer to the window which
  1210.                the proportional gadget is connected to.
  1211.   
  1212.   requester:   (struct Requester *) If the gadget is connected
  1213.                to a requester, set this pointer to point to
  1214.                that requester, else NULL. Important, if this
  1215.                gadget is connected to a requester, it must be
  1216.                displayed when you execute this command!
  1217.  
  1218.   flags:       (long) Here is the list of all flags you may
  1219.                use:
  1220.   
  1221.                  FREEHORIZ      Set this bit if you want the
  1222.                                 user to be able to move the
  1223.                                 knob horizontally.
  1224.  
  1225.                  FREEVERT       Set this bit if you want the
  1226.                                 user to be able to move the
  1227.                                 knob vertically.
  1228.  
  1229.                  AUTOKNOB       Set this bit if you want that
  1230.                                 the size of the knob to be
  1231.                                 controlled by Intuition.
  1232.                                 (HorizBody and VertBody
  1233.                                 affects the size of the
  1234.                                 Autoknob.)
  1235.  
  1236.                                 - If you want to use
  1237.                                 Intuition's Autoknob you
  1238.                                 should give GadgetRender a
  1239.                                 pointer to an Image structure.
  1240.                                 (You do not need to initialize
  1241.                                 the Image structure since
  1242.                                 Intuition takes care of it.)
  1243.  
  1244.                                 - If you on the other hand
  1245.                                 would like to use your own
  1246.                                 knob image, you give
  1247.                                 GadgetRender a pointer to your
  1248.                                 Image structure, which you have
  1249.                                 initialized yourself.
  1250.  
  1251.                  PROPBORDERLESS Set this bit if you do not
  1252.                                 want any border around the
  1253.                                 container. 
  1254.  
  1255.                (See chapter 4.7 for more information.)
  1256.  
  1257.   horiz_pot:   (long) This variable contains the actual
  1258.                (horizontally) proportional value. If the knob
  1259.                should be moved 25% to the right, HorizPot
  1260.                should be set to 25% of MAXPOT (0xFFFF).
  1261.                (0xFFFF * 0.25 = 0x3FFF)
  1262.  
  1263.   vert_pot:    (long) Same as HorizPot except that this is the
  1264.                vertically proportional value.
  1265.  
  1266.   horiz_body:  (long) Describes how much HorizPot should change
  1267.                every time the user clicks inside the container.
  1268.                If the volume of a melody can be between 0-63
  1269.                (64 steps), HorizPot should change 1/64 each
  1270.                time. The HorizBody should therefore be set to:
  1271.                1/64 * MAXBODY (0xFFFF) == 3FF
  1272.  
  1273.                HorizBody describes also how much the user can
  1274.                see/use of the entire data. For example, if you
  1275.                have a list of 32 file names, and the user only
  1276.                can see 8 names at one time (25%), the knob
  1277.                (AUTOKNOB) should fill 25% of the container.
  1278.                HorizBody should in this case be set to:
  1279.                MAXBODY * 8 / 32 (25% of 0xFFFF) == 3FFFF
  1280.  
  1281.  
  1282.   vert_body:   Same as HorizBody except that it affects
  1283.                VertPot, and the vertical size of the knob
  1284.                (AUTOKNOB).
  1285.  
  1286.  
  1287. 4.10  EXAMPLES
  1288.  
  1289. Example1
  1290.   This program will open a normal window which is connected to
  1291.   the Workbench Screen. The window will use all System
  1292.   Gadgets, and will close first when the user has selected the
  1293.   System gadget Close window. (Same as Example3 in chapter 2
  1294.   WINDOWS, except that we have added an IDCMP check on the
  1295.   Close window gadget.)
  1296.  
  1297. Example2
  1298.   Same as Example1 except that we have added a Boolean gadget
  1299.   with the text "PRESS ME".
  1300.  
  1301. Example3
  1302.   Same as Example2 except that the on/off state of the gadget
  1303.   is toggled each time the user hits the gadget.
  1304.  
  1305. Example4
  1306.   This program will open a normal window which is connected to
  1307.   the Workbench Screen. The window will use all System
  1308.   Gadgets, and will close first when the user has selected
  1309.   the System gadget Close window. Inside the window we have put
  1310.   two Boolean gadgets with the text "GADGET 1" and "GADGET 2".
  1311.  
  1312. Example5
  1313.   This program will open a normal window which is connected to
  1314.   the Workbench Screen. The window will use all System Gadgets,
  1315.   and will close first when the user has selected the System
  1316.   gadget Close window. Inside the window we have put a Boolean
  1317.   gadget with two Image structures connected to it. Each time
  1318.   the user clicks on the gadget it will change images, lamp
  1319.   on/lamp off.
  1320.  
  1321. Example6
  1322.   This program will open a normal window which is connected
  1323.   to the Workbench Screen. The window will use all System
  1324.   Gadgets, and will close first when the user has selected the
  1325.   System gadget Close window. Inside the window we have put a
  1326.   Boolean gadget with a connecting mask. The gadget will only
  1327.   be highlighted when the user selects this gadget while
  1328.   pointing inside the specified (masked) area.
  1329.  
  1330. Example7
  1331.   This program will open a normal window which is connected to
  1332.   the Workbench Screen. The window will use all System
  1333.   Gadgets, and will close first when the user has selected the
  1334.   System gadget Close window. Inside the window we have put a
  1335.   String gadget.
  1336.  
  1337. Example8
  1338.   Same as Example7 except that it is an Integer gadget.
  1339.  
  1340. Example9
  1341.   Same as Example7 except that it is a Proportional gadget.
  1342.  
  1343. Example10
  1344.   Same as Example9 except that the Proportional gadget uses a
  1345.   custom image knob.
  1346.  
  1347. Example11
  1348.   This program will open a normal window which is connected to
  1349.   the Workbench Screen. The window will use all System
  1350.   Gadgets, and will close first when the user has selected the
  1351.   System gadget Close window. Inside the window we have put a
  1352.   Proportional gadget where the knob can be moved both
  1353.   horizontally and vertically.
  1354.  
  1355. Example12
  1356.   This program will open a SuperBitmap window which is
  1357.   connected to the Workbench Screen. The window will use all
  1358.   System Gadgets, and will close first when the user has
  1359.   selected the System gadget Close window. Inside the window we
  1360.   have put two Proportional gadgets, one on the right side, and
  1361.   one at the bottom. With help of these two gadgets, the user
  1362.   can move around the BitMap.
  1363.  
  1364.   This example is for experienced programmers only, since it
  1365.   uses some functions etc which we have not discussed yet. I
  1366.   have, however, included it here since it is a good example on
  1367.   how you can combine Proportional gadgets with SuperBitmap
  1368.   windows.